package com.jch.mp.manner1.server;

import com.alibaba.fastjson.JSON;
import com.jch.mp.manner1.domain.message.ComplexMessage;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

import java.text.SimpleDateFormat;
import java.util.Date;

public class ComplexMessageHandler extends SimpleChannelInboundHandler<ComplexMessage> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, ComplexMessage msg) throws Exception {
        System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS").format(new Date()) + " 收到消息: " + JSON.toJSONString(msg));
        ctx.writeAndFlush(msg);
    }
}
